#include <iostream>
#include <string>
using namespace std;

#define N 100010
// 跟静态单链表思路一致
int e[N];
int pev[N];
int nex[N];
int idx;
// 双链表的题用带头尾两个哨兵节点的链表做,不用修改头尾指针
void init()
{
    idx = 2;
    nex[0] = 1;
    pev[1] = 0;
}
void insert_right(int i, int x)
{
    e[idx] = x;
    nex[idx] = nex[i];
    pev[idx] = i;
    pev[nex[i]] = idx;
    nex[i] = idx;
    idx++;
}
void insert_left(int i, int x)
{
    e[idx] = x;
    nex[idx] = i;
    pev[idx] = pev[i];
    nex[pev[i]] = idx;
    pev[i] = idx;
    idx++;
}
void push_back(int x)
{
    insert_left(1, x);
}
void push_front(int x)
{
    insert_right(0, x);
}
void earse(int i)
{
    nex[pev[i]] = nex[i];
    pev[nex[i]] = pev[i];
}
int main()
{
    init();
    int n;
    cin >> n;
    while (n--)
    {
        char op;
        cin >> op;
        if (op == 'R')
        {
            int x;
            cin >> x;
            push_back(x);
        }
        else if (op == 'L')
        {
            int x;
            cin >> x;
            push_front(x);
        }
        else if (op == 'D')
        {
            int k;
            cin >> k;
            earse(k + 1);
        }
        else
        {
            char op2;
            cin >> op2;
            int k, x;
            cin >> k >> x;
            if (op2 == 'L')
            {
                insert_left(k + 1, x);
            }
            else
            {
                insert_right(k + 1, x);
            }
        }
    }
    for (int i = nex[0]; i != 1; i = nex[i])
    {
        cout << e[i] << ' ';
    }
    return 0;
}